package com.shsnc.agent;

import java.lang.instrument.Instrumentation;

import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.matcher.ElementMatchers;

/**
 *
 * @author zll
 * @date 2021/8/5
 *
 * 主类
 */
public class PreMainAgent {

	public static void premain(String args, Instrumentation instrumentation){
		//增强操作
		AgentBuilder.Transformer transformer=new LogAddTransformer();
		//将transformer添加至JavaAgent的Instrumentation实例上
		//对com.shsnc.log.record.service.LogRecordService进行增强
		new AgentBuilder.Default().type(ElementMatchers.named("com.shsnc.log.record.service.LogRecordService"))
				.transform(transformer).installOn(instrumentation);

	}
}
